"""Seam_WP URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path,re_path,include
from django.conf import settings
from django.conf.urls.static import static

from django.contrib.sitemaps.views import sitemap
from blog.sitemaps import ArticleSitemap, CategorySitemap, TagSitemap
from blog.feeds import AllArticleRssFeed
from blog import views





# 网站地图
sitemaps = {
    'articles': ArticleSitemap,
    'tags': TagSitemap,
    'categories': CategorySitemap
}

urlpatterns = [
    path('',views.IndexView.as_view()),
    path('admin/', admin.site.urls),
    path('admin/doc/',include('django.contrib.admindocs.urls')),
    path('api/',include("api.urls",namespace="api")),
    path("blog/",include("blog.urls",namespace="blog")),
    path("accounts/",include("accounts.urls",namespace="accounts")),
    path('sitemap.xml', sitemap, {'sitemaps': sitemaps}, name='django.contrib.sitemaps.views.sitemap'),  # 网站地图
    path('feed/', AllArticleRssFeed(), name='rss'),   # rss订阅
    re_path(r'^search/$', views.MySearchView.as_view(), name='search'),
]

urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

# 全局403
handler403 = 'blog.views.page_forbidden'

# 全局404
handler404 = 'blog.views.page_not_found'

# 全局500
handler500 = 'blog.views.page_error'